home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / appletalk / uab.shar / aarp_defs.h next >
C/C++ Source or Header  |  1990-07-12  |  4KB  |  129 lines

  1. /*
  2.  * $Author: cck $ $Date: 88/09/14 10:19:02 $
  3.  * $Header: /src/local/mac/cap/etalk/RCS/aarp_defs.h,v 1.5 88/09/14 10:19:02 cck Rel $
  4.  * $Revision: 1.5 $
  5. */
  6.  
  7. /*
  8.  * aarp_defs.h Apple Address Resolution Protocol definitions
  9.  *
  10.  * Meant only for the aarp module!
  11.  *
  12.  * Copyright (c) 1988 by The Trustees of Columbia University 
  13.  *  in the City of New York.
  14.  *
  15.  * Permission is granted to any individual or institution to use,
  16.  * copy, or redistribute this software so long as it is not sold for
  17.  * profit, provided that this notice and the original copyright
  18.  * notices are retained.  Columbia University nor the author make no
  19.  * representations about the suitability of this software for any
  20.  * purpose.  It is provided "as is" without express or implied
  21.  * warranty.
  22.  *
  23.  *
  24.  * Edit History:
  25.  *
  26.  *  August 1988  CCKim Created
  27.  *
  28. */
  29.  
  30. #define AARP_DUMP_TABLE "yes" /* turn this on */
  31.  
  32. /*
  33.  * AARP Ethernet type
  34.  *
  35. */
  36. #ifndef ETHERTYPE_AARP 0x80f3
  37. # define ETHERTYPE_AARP 0x80f3
  38. #endif
  39.  
  40. /* probe op, define if not defined */
  41. #ifndef ARPOP_PROBE
  42. # define ARPOP_PROBE 3
  43. #endif
  44.  
  45. /*
  46.  * AARP table management
  47.  *
  48. */
  49.  
  50. /* An ethertalk node address (should probably merge with aarptab) */
  51. typedef struct aarp_entry {
  52.   struct ethertalkaddr aae_pa;    /* protocol address */
  53.   int aae_flags;        /* flags */
  54. #define AARP_OKAY 0x1        /* resolved */
  55. #define AARP_RESOLVING 0x2    /* trying to resolve this */
  56. #define AARP_PERM 0x4        /* permanent (not used) */
  57. #define AARP_FNAME_OKAY(f) ((f&AARP_OKAY) ? "okay " : "")
  58. #define AARP_FNAME_RESOLVING(f) ((f&AARP_RESOLVING) ? "resolving " : "")
  59. #define AARP_FNAME_PERM(f) ((f&AARP_PERM) ? "perm " : "")
  60.   u_char aae_eaddr[EHRD];    /* hardware address */
  61.   int aae_ttl;            /* time to live */
  62.   int aae_used;            /* # of times used */
  63.   struct aarp_entry *aae_next;    /* next in list of all */
  64.   caddr_t aae_aarptab;        /* back pointer */
  65. } AARP_ENTRY;
  66.  
  67.  
  68. /* time to live */
  69. #define AARP_TTL 5        /* 4*AARP_SCAN_TIME */
  70. #define AARP_SCAN_TIME (60)    /* scan every minute  */
  71. /* we adjust ttls if an incoming probe comes in */
  72. /* if the ha is the same, ttl gets dropped.  if the ha */
  73. /* is different, the ttl is smacked dead */ 
  74. #define AARP_PROBED_SAME 1    /* set time to live to AARP_SCAN_TIME */
  75. #define AARP_PROBED_DIFF 0    /* set time to live to zero */
  76.  
  77. /*
  78.  * AARP probe/request managment
  79.  *
  80. */
  81. /* number of times to probe an address */
  82. #define AARP_PROBE_TRY 15
  83. /* timeout between probes */
  84. #define AARP_PROBE_TIMEOUT_SEC 0
  85. #define AARP_PROBE_TIMEOUT_USEC 100000 /* 1/10 second */
  86. /* same for requests */
  87. #define AARP_REQUEST_TRY 10
  88. #define AARP_REQUEST_TIMEOUT_SEC 0
  89. #define AARP_REQUEST_TIMEOUT_USEC 250000 /* 1/4th second */
  90.  
  91. /*
  92.  * AARP table/interface management
  93.  *
  94. */
  95. /* number of buckets in the aarp hash table */
  96. #define AARP_TAB_SIZE 15
  97.  
  98. /*
  99.  * one of these are created for every "interface" open
  100.  *
  101. */
  102. typedef struct aarp_interface_handle {
  103.   int ai_ph;            /* protocol handle */
  104.   caddr_t ai_aarptab;        /* aarp table */
  105.   int ai_accesses;        /* count of access to arp tabl */
  106. #define AI_AARPTAB_EVAL_POINT 2000
  107. #define AI_AARPTAB_REHASH_POINT 200 /* more than avg. of 2 access */
  108.   struct ai_host_node {        /* host's node table */
  109.     struct ethertalkaddr aihn_pa; /* our protocol address */
  110.     int aihn_state;
  111. #define AI_NODE_UNUSED 0    /* node not in use */
  112. #define AI_NODE_PROBE -1    /* node in probe state */
  113. #define AI_NODE_OKAY 1        /* node okay */
  114.   } *ai_nodes;
  115.   int ai_maxnode;
  116.   int ai_numnode;        /* number of nodes in use */
  117.   int ai_flags;            /* interface flags */
  118.   u_char ai_eaddr[EHRD];    /* enet addr */
  119.   /* probably should return this integer instead of the handle */
  120. } AI_HANDLE;
  121.  
  122.  
  123. /* exported procedure definitions */
  124. export caddr_t aarp_init();
  125. export int aarp_resolve();
  126. export int aarp_insert();
  127. export int aarp_acquire_etalk_node();
  128.  
  129.